package com.wv.api.server.system;

import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
import com.wv.api.server.common.BaseController;
import com.wv.api.service.ILoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
@Api(tags = "登录相关接口")
public class LoginController extends BaseController {

    @Autowired
    private ILoginService loginService;

    @GetMapping("/login")
    @ApiOperation(value = "登录接口")
    public SaResult login(String name, String password) {
        return loginService.login(name,password);
    }

    @GetMapping("/logout")
    @ApiOperation(value = "退出登录")
    public SaResult logout() {
        StpUtil.logout();
        return success("退出成功");
    }
}
